package com.cowin.sys.controller;
import com.cowin.base.result.Result;
import com.cowin.base.result.ResultGenerator;
import com.cowin.base.BaseController;
import com.cowin.sys.model.TmBasLine;
import com.cowin.sys.model.TmBasWorkschedule;
import com.cowin.sys.model.TmBasWorkshop;
import com.cowin.sys.model.dto.WorkAndRest;
import com.cowin.sys.model.vo.IdNameVo;
import com.cowin.sys.model.vo.LineVo;
import com.cowin.sys.service.TmBasWorkscheduleService;
import com.cowin.sys.service.TmBasWorkshopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import java.util.List;

/**
 * Created by  on 2019/10/30.
 * @author CodeGenerator
 */
@Slf4j
@Api(value = "TmBasWorkshopController", description = "车间基本信息控制器", tags = "TmBasWorkshopController", consumes = "application/json")
@RestController
@RequestMapping("/tm/bas/workshop")
public class TmBasWorkshopController extends BaseController<TmBasWorkshop>{
    @Resource
    private TmBasWorkshopService tmBasWorkshopService;

    @Resource
    private TmBasWorkscheduleService tmBasWorkscheduleService;

    @ApiOperation(value = "查询上线产线信息")
    @GetMapping("/online/{type}")
    public Result getLineInfoByCode(@PathVariable String type){
        List<LineVo> list = tmBasWorkshopService.findLineInfoByType(type);
        return ResultGenerator.genSuccessResult(list);
    }
    @ApiOperation(value = "查询车间下的产线信息")
    @GetMapping("/line/{id}")
    public Result getLine(@PathVariable Long id){
        List<TmBasLine>  list = tmBasWorkshopService.getLineById(id);
        return ResultGenerator.genSuccessResult(list);
    }

    @ApiOperation(value = "根据车间ID 查询车间工作日历", notes = "根据车间ID 查询车间工作日历")
    @GetMapping("/shop/{workshopId}")
    public Result getWorkshopSchedule(@PathVariable Long workshopId) {
        List<WorkAndRest> list =  tmBasWorkscheduleService.getWorkshopSchedule(workshopId);
        return ResultGenerator.genSuccessResult(list);
    }

}
